package maosy.oauth2.password.test.spring.mapper

import maosy.oauth2.password.entities.TbUserEntity
import maosy.oauth2.password.repository.UserRepository
import maosy.oauth2.password.test.spring.SpringTest
import maosy.oauth2.password.util.uuid
import org.junit.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
import org.springframework.security.crypto.factory.PasswordEncoderFactories
import java.util.*

class UserRepositoryTest : SpringTest() {

    @Autowired
    private lateinit var userRepository: UserRepository

    @Test
    fun userSave() {
        val rest = userRepository.save(TbUserEntity().apply {
            id = String.uuid()
            password = BCryptPasswordEncoder().encode("123456")
            userName = "admin"
            isDelete = false
            userType = 2
            userState = 1
            createTime = Date()
            realName="系统管理员"
        })
        println(gson.toJson(rest))
    }
}